<template>
  <div class="live">
    <div class="head_box">
      <div class="live-tab">
        <div
          class="live-tab__item"
          v-for="tab in liveTab"
          :key="tab.title"
          @tap="selTab(tab)"
        >
          <div class="live-tab__item-name">{{ tab.name }}</div>
          <text
            class="live-tab__item--link"
            :class="{ 'live-tab__item--active': tabCur == tab.title }"
          ></text>
        </div>
      </div>
    </div>
    <div class="content_box">
      <div class="scroll-box">
        <div class="list-box">
          <div
            class="sp-live-card"
            v-for="(detail, index) in componentContent.liveList"
            :key="index"
          >
            <div class="live-content">
              <img
                class="item-cover"
                :src="detail.shareImge"
              />
              <div class="item-status">
                <img
                  class="status-img"
                  :src="liveStatus[detail.liveStatus].img"
                />
                <text class="status-text">{{
                  liveStatus[detail.liveStatus].title
                }}</text>
              </div>
              <div class="item-title">{{ detail.name }}</div>
            </div>
            <div class="live-bottom">
              <div class="live-info">
                <div class="info-box">
                  <div class="info-name">{{ detail.anchorName }}</div>
                </div>
              </div>
              <slot name="liveGoods">
                <div
                  class="live-goods"
                  v-if="detail.product && detail.product.length"
                >
                  <div
                    class="live-goods__item"
                    v-for="(goods, index) in detail.product"
                    :key="goods.goodsId"
                  >
                    <img
                      class="live-goods__img"
                      :src="goods.coverImgeUrl"
                    />
                    <div
                      class="live-goods__price"
                      v-if="index < 2"
                    >
                      ￥{{ goods.price }}
                    </div>
                    <div
                      class="live-goods__mark"
                      v-else
                    >
                      <text>{{ detail.product.length }}+</text>
                    </div>
                  </div>
                </div>
              </slot>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
  export default {
    name: "shopLiveCard",
    components: {},
    data() {
      return {
        tabCur: "all",
        liveStatus: "",
        loaded: false,
        loading: false,
        liveTab: [{
            title: "all",
            name: "全部",
            code: "",
          },
          {
            title: "prevue",
            name: "预告",
            code: "102",
          },
          {
            title: "living",
            name: "直播中",
            code: "101",
          },
          {
            title: "lived",
            name: "已结束",
            code: "103",
          },
        ],
        loadStatus: "", //loading,over
        currentPage: 0,
        size: 10,
        lastPage: 0,
        liveStatus: {
          101: {
            img: "https://wx.yixiang.co/static/images/live.png",
            title: "直播中",
          },
          102: {
            img: "https://wx.yixiang.co/static/images/prevue.png",
            title: "未开始",
          },
          103: {
            img: "https://wx.yixiang.co/static/images/playback.png",
            title: "已结束",
          },
          104: {
            img: "https://wx.yixiang.co/static/images/104.png",
            title: "禁播",
          },
          105: {
            img: "https://wx.yixiang.co/static/images/105.png",
            title: "暂停中",
          },
          106: {
            img: "https://wx.yixiang.co/static/images/106.png",
            title: "异常",
          },
          107: {
            img: "https://wx.yixiang.co/static/images/past.png",
            title: "已过期",
          },
        },
      };
    },
    props: {
      componentContent: Object,
      detail: {
        type: Object,
        default: null,
      },
      wh: {
        type: Number,
        default: 345,
      },
    },
  };

</script>

<style lang="scss">
  // tab
  .live-tab {
    width: 100%;
    height: 96/750*500px;
    background: #fff;
    display: flex;
    align-items: center;

    &__item {
      flex: 1;
      height: 100%;
      display: flex;
      flex-direction: column;
      justify-content: space-between;
      align-items: center;
    }

    &__item-name {
      font-size: 28/750*500px;
      font-family: PingFang SC;
      font-weight: bold;
      color: rgba(51, 51, 51, 1);
      flex: 1;
      display: flex;
      justify-content: center;
      align-items: center;
    }

    &__item--link {
      width: 68/750*500px;
      height: 4/750*500px;
      background: transparent;
      border-radius: 2/750*500px;
    }

    &__item--active {
      width: 68/750*500px;
      height: 4/750*500px;
      background: rgba(213, 166, 90, 1);
      border-radius: 2/750*500px;
    }
  }

  // 瀑布流 list
  .scroll-box {
    .list-box {
      width: 100%;
      column-count: 2;
      padding: 25/750*500px;
    }
  }

  .sp-live-card {
    width: 344/750 * 500px;
    box-shadow: 0px 0px 10/750 * 500px 4/750 * 500px rgba(199, 199, 199, 0.22);
    border-radius: 20/750 * 500px;
    height: 100%;
    overflow: hidden;
    margin-bottom: 20/750 * 500px;
  }

  .live-content {
    position: relative;
    width: 344/750 * 500px;
    height: 344/750 * 500px;
    overflow: hidden;

    .item-cover {
      background-color: #eee;
      width: 100%;
      height: 100%;
      border-radius: 20/750 * 500px 20/750 * 500px 0 0;
    }

    .item-status {
      position: absolute;
      top: 20/750 * 500px;
      left: 10/750 * 500px;
      height: 40/750 * 500px;
      background: rgba(0, 0, 0, 0.4);
      border-radius: 20/750 * 500px;
      display: flex;
      justify-content: center;
      align-items: center;

      .status-img {
        width: 40/750 * 500px;
        height: 40/750 * 500px;
      }

      .status-text {
        font-size: 22/750 * 500px;
        font-family: PingFang SC;
        font-weight: 500;
        color: rgba(255, 255, 255, 1);
        padding: 0 10/750 * 500px;
      }
    }

    .item-title {
      width: 345/750 * 500px;
      position: absolute;
      bottom: 0;
      line-height: 60/750 * 500px;
      padding: 0 20/750 * 500px;
      font-size: 26/750 * 500px;
      font-family: PingFang SC;
      font-weight: 500;
      color: rgba(255, 255, 255, 1);
      background: linear-gradient(transparent, rgba(#000, 0.5));
      padding-right: 60/750 * 500px;
    }

    .like-img {
      position: absolute;
      bottom: 20/750 * 500px;
      right: 10/750 * 500px;
      width: 60/750 * 500px;
      height: 130/750 * 500px;
    }
  }

  .live-bottom {
    background-color: #fff;
    padding: 20/750 * 500px;
    width: 345/750 * 500px;

    .live-info {
      display: flex;
      justify-content: space-between;
      align-items: center;
      width: 100%;

      .info-box {
        display: flex;
        align-items: center;
      }

      .info-avatar {
        width: 40/750 * 500px;
        height: 40/750 * 500px;
        border-radius: 50%;
        margin-right: 10/750 * 500px;
        background: #eee;
      }

      .info-name {
        width: 150/750 * 500px;
        font-size: 24/750 * 500px;
        font-family: PingFang SC;
        font-weight: 500;
        color: rgba(51, 51, 51, 1);
      }

      .divs {
        font-size: 20/750 * 500px;
        font-family: PingFang SC;
        font-weight: 400;
        color: rgba(153, 153, 153, 1);
      }
    }

    .live-goods {
      display: flex;
      align-items: center;
      margin-top: 20/750 * 500px;

      &__item {
        position: relative;
        width: 96/750 * 500px;
        height: 96/750 * 500px;
        border: 1/750 * 500px solid rgba(238, 238, 238, 1);
        border-radius: 10/750 * 500px;
        overflow: hidden;
        margin-right: 8/750 * 500px;

        &:nth-child(3n) {
          margin-right: 0;
        }
      }

      &__img {
        background: #eee;
        width: 100%;
        height: 100%;
      }

      &__price {
        position: absolute;
        bottom: 0;
        line-height: 40/750 * 500px;
        width: 100%;
        background: linear-gradient(transparent, rgba(#000, 0.5));
        font-size: 20/750 * 500px;
        color: #fff;
      }

      &__mark {
        position: absolute;
        width: 100%;
        height: 100%;
        top: 0;
        left: 0;
        margin: auto;
        display: flex;
        justify-content: center;
        align-items: center;

        background: rgba(#000, 0.3);
        font-size: 24/750 * 500px;
        font-family: PingFang SC;
        font-weight: 500;
        color: rgba(255, 255, 255, 1);
      }
    }
  }

</style>
